package com.hls.modules.sysjob.job;

import com.hls.modules.business.entity.MedicalRecord;
import com.hls.modules.business.service.MedicalRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.io.UnsupportedEncodingException;
import java.util.List;

@Component("analysisMzMedicalRecordJob")
@Slf4j
public class AnalysisMzMedicalRecordJob {
    @Autowired
    private MedicalRecordService medicalRecordService;
    /**
     * 解析门诊病历
     * @return
     */
    public void analysisMzMedicalRecordJob() {
        log.info("解析门诊病历定时任务开始执行=================");
        MedicalRecord medicalRecord = new MedicalRecord();
        medicalRecord.setBlfl("1");
        List<MedicalRecord> medicalRecordList = medicalRecordService.medicalRecordList(medicalRecord);

        if(!CollectionUtils.isEmpty(medicalRecordList)) {
            System.out.println("解析门诊病历定时任务开始执行=================获取病历数：" + medicalRecordList.size());
            for(MedicalRecord mr : medicalRecordList) {
                try {
                    System.out.println(new String(mr.getBlnr(), "GBK"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
